package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsBrandMapper;
import com.qf.pojo.DtsBrand;
import com.qf.service.DtsBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZhangYuJie
 * projectName:shop_manage
 * time:2022/5/17 21:23
 * description:
 */
@Service
public class DtsBrandServiceImpl implements DtsBrandService {
    @Autowired
    private DtsBrandMapper brandMapper;

    @Override
    public DtsBrand findById(Integer id) {
        return brandMapper.selectById(id);
    }

    @Override
    public List<DtsBrand> all() {
        QueryWrapper<DtsBrand> wapper = new QueryWrapper<>();
        wapper.eq("deleted", false);
        return brandMapper.selectList(wapper);
    }

    @Override
    public List<DtsBrand> getAdminBrands(Integer adminId) {
        if (adminId == null) {
            return null;
        }
        QueryWrapper<DtsBrand> wapper = new QueryWrapper<>();
        wapper.eq("deleted", false);
        wapper.eq("admin_id", adminId);
        return brandMapper.selectList(wapper);
    }
}
